import 'package:flutter/material.dart';
import 'package:liquid_pull_to_refresh/liquid_pull_to_refresh.dart';

class LiquiPullToRefreshWrapper extends StatelessWidget {
  LiquiPullToRefreshWrapper(
      {super.key, required this.child, required this.onRefresh});

  // child widget to be wrapped
  final Widget child;

  // onRefresh callback function
  final Future<void> Function() onRefresh;

  // Global key for LiquidPullToRefresh
  final GlobalKey<LiquidPullToRefreshState> _refreshIndicatorKey = GlobalKey();

  @override
  Widget build(BuildContext context) {
    return LiquidPullToRefresh(
      key: _refreshIndicatorKey,
      height: 50.0,
      showChildOpacityTransition: false,
      springAnimationDurationInMilliseconds: 100,
      onRefresh: onRefresh,
      child: child,
    );
  }
}
